package com.his.dictresource.service.impl;

import com.his.dictresource.dao.DictResourceMapper;
import com.his.dictresource.entity.DictResource;
import com.his.dictresource.entity.DictResources;
import com.his.dictresource.service.DictResourceService;
import com.his.dictresource.vo.DictResourceVo;
import com.his.login.entity.DictEmployee;
import com.xiao.common.util.BeanUtil;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;

import javax.annotation.Resource;
import java.util.List;

@Service
public class DictResourceServiceImpl implements DictResourceService {
    @Resource
    private DictResourceMapper dictResourceMapper;

    @Override
    public List<DictResources> selectDictResourceList(DictEmployee employee, DictResourceVo dictResourceVo) {
        DictResources dictResource = BeanUtil.copyBean(dictResourceVo,DictResources.class);
        dictResource.setHospid(employee.getHOSPID());
        return dictResourceMapper.resource_list(dictResource);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void insertDictResource(DictResourceVo dictResourceVo) {
        DictResource dictResource = BeanUtil.copyBean(dictResourceVo,DictResource.class);
        dictResourceMapper.resource_del(dictResource.getResourcetypeid(),dictResource.getResourceid(),dictResource.getDatetypeid());
        dictResourceMapper.resource_add(dictResource);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteDictResource(String resourceTypeId,String resourceId,String dateTypeId) {
        dictResourceMapper.resource_del(resourceTypeId,resourceId,dateTypeId);
    }
}
